# -*- coding:utf-8 -*-
def extend(format,d,marks='"',safe=False):
	"""docstring for extend"""
	if safe:
		def look(w):
			return d.get(w,"".join(w))
	else:
		def look(w):
			return d[w]
	parts = format.split(marks)
	parts[1::2] = map(look,parts[1::2])
	return ''.join(parts)
if __name__ == '__main__':
	print extend('this is "a" test',{'a':'one'})
	print "test"
